package com.study.mike.spring.sample.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

public class AspectAdviceBean {

	public void before1() {
		System.out.println(">> AspectAdviceBean#before1 增强 ");
	}

	public void before2(JoinPoint jp) {
		System.out.println(">> AspectAdviceBean#before2 增强: jp=" + jp);
	}

	public void before3(String tk) {
		System.out.println(">> AspectAdviceBean#before3 增强: tk=" + tk);
	}

	public void before4(String tk, int ti) {
		System.out.println(">> AspectAdviceBean#before4 增强: tk=" + tk + ", ti=" + ti);
	}

	//只有环绕的参数必须用ProceedingJoinPoint, 其他用JoinPoint, 两者都要放在参数列表第一位
	public Object around1(ProceedingJoinPoint pjp) throws Throwable {
		System.out.println(">> AspectAdviceBean#around1 环绕-前增强: pjp=" + pjp);
		Object ret = pjp.proceed();
		System.out.println(">> AspectAdviceBean#around1 环绕-后增强: pjp=" + pjp);
		return ret;
	}

	public Object around2(ProceedingJoinPoint pjp, String name) throws Throwable {
		System.out.println(">> AspectAdviceBean#around2 name=" + name);
		System.out.println(">> AspectAdviceBean#around2 环绕-前增强 pjp=" + pjp);
		Object ret = pjp.proceed();
		System.out.println(">> AspectAdviceBean#around2 环绕-后增强 pjp=" + pjp);
		return ret;
	}

	public void afterReturning(Object retValue) {
		System.out.println(">> AspectAdviceBean#afterReturning 增强, 返回值=" + retValue);
	}

	public void afterThrowing(JoinPoint jp, Exception e) {
		System.out.println(">> AspectAdviceBean#afterThrowing 增强: jp=" + jp);
		System.out.println(">> AspectAdviceBean#afterThrowing 增强: 异常=" + e);
	}

	public void after(JoinPoint jp) {
		System.out.println(">> AspectAdviceBean#after 增强: jp=" + jp);
	}

}
